package com.panpay.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html; charset=UTF-8");
//        存储数据
        req.setAttribute("msg","Hello freemarker被获取的数据");
        req.setAttribute("flag",true);
//       转发   转发到template目录下的f01文件（该文件必须先存在）
        req.getRequestDispatcher("template/freebase.ftl").forward(req,resp);
    }
}
